<div class="judul"><?php echo anchor("/info_keuangan_adik_asuh/",$title);?></div>
<?php
  $uri_segment = $this->uri->segment(3);
  if($uri_segment != "" && $uri_segment != "all"){
      $option = parsing_param2($uri_segment);
      $awal = datefmysql($option['awal']);
      $akhir = datefmysql($option['akhir']);
      $adik_asuh = $option['adikAsuh'];
      $id_adik_asuh = $option['idAdikAsuh'];
  }else{
      $awal = date("d/m/Y");
      $akhir = date("d/m/Y");
      $adik_asuh = "";
      $id_adik_asuh = "";
  }
?>
<script type="text/javascript">
$(document).ready(function(){   
  $('#adik_asuh').autocomplete("<?php echo site_url('ajax_target/searchAdikAsuh');?>",
        {
            parse: function(data){
                var parsed = [];
                for (var i=0; i < data.length; i++) {
                    parsed[i] = {
                        data: data[i],
                        value: data[i].nama // nama field yang dicari
                    };
                }
                return parsed;
            },
            formatItem: function(data,i,max){
                var str='<div class=result>'+data.nama+'<br />Alamat: '+data.alamat+'<br />Sekolah: '+data.sekolah+'</div>';
                return str;
            },
            width: 270, // panjang tampilan pencarian autocomplete yang akan muncul di bawah textbox pencarian
            dataType: 'json' // tipe data yang diterima oleh library ini disetup sebagai JSON
        }).result(
            function(event,data,formated){
                $(this).val(data.nama);
                $('#id_adik_asuh').val(data.id);
//                $('#alamat').html(data.alamat);
//                $('#sekolah').html(data.sekolah);
//                $('#id_sekolah').val(data.id_sekolah);
//                $('#kelas').html(data.kelas);
//                $('#id_kelas').val(data.id_kelas);
//                $('#tahun_ajaran').html(data.tahun_ajaran+" "+data.semester);
//                $('#id_tahun_ajaran').val(data.id_tahun_ajaran);
        });
}) 
</script>
<div class="data-input">
    <fieldset>
        <legend><?php echo "$formTitle";?></legend>
        <?php 
          echo form_open("info_keuangan_adik_asuh/search");
        ?>
        <fieldset class="field-group">
            <legend>Tanggal</legend>
            <?php echo form_input("awal", $awal, "id='awal' class='tanggal datepicker-input'")?>
            <label class="inline-title">s.d</label>
            <?php echo form_input("akhir", $akhir, "id='akhir' class='tanggal datepicker-input'")?>
        </fieldset>
        <label>Adik Asuh</label><?php echo form_input("adik_asuh", $adik_asuh, "id='adik_asuh'")?>
        <input type="hidden" name="id_adik_asuh" id="id_adik_asuh" value="<?php echo "$id_adik_asuh";?>"/>
        <fieldset class="input-process">
            <?php
              echo form_hidden("url", $searchLink);
              echo form_submit('add', 'Cari', 'class=button style=margin-right:2px');
              echo form_button('Batal', 'Batal', 'class=button onClick='."javascript:location.href='".base_url()."index.php/info_keuangan_adik_asuh/'".'');
              echo form_close();
            ?>
        </fieldset>    
    </fieldset>
</div>
<fieldset>
<?php
  if($uri_segment == ''){
      echo "<span class='tips'>Silahkan menggunakan opsi pencarian di atas</span>";
  }else{
?>    
<div class="data-list">
    <div style="float: right">
        <span class="cetak" onclick="window.open('<?php echo base_url()."index.php/info_keuangan_adik_asuh/print_keuangan_adik_asuh/$uri_segment"?>', 'mywindow', 'width=1000','height=850')">cetak</span>
        <a class="excel" href="<?php echo site_url('info_keuangan_adik_asuh/export_data').'/'.$uri_segment?>">cetak</a>
    </div>
    <table class="tabel" style="width: 100%">
        <tr>
            <th style="width:3%">No</th>
            <th style="width:5%">Tanggal</th>
            <th style="width:10%">Petugas</th>
            <th style="width:10%">Adik Asuh</th>
            <th>Sekolah</th>
            <th style="width:5%">Kelas</th>
            <th style="width:8%">Tahun Ajaran</th>
            <th>Keterangan</th>
            <th style="width:8%">Debet (Rp.)</th>
            <th style="width:8%">Kredit (Rp.)</th>
            <th style="width:8%">Saldo (Rp.)</th>
        </tr>
        <?php
          $offsets = isset ($offset)?$offset:0;
          $no = 1 + $offsets;
          foreach ($listKeuanganAdikAsuh as $row){
        ?>
        <tr class="<?php echo ($no%2)?"even":"odd"?>">
            <td align="center"><?php echo $no++;?></td>
            <td><?php echo datefmysql($row['tanggal']);?></td>
            <td><?php echo $row['petugas'];?></td>
            <td><?php echo $row['adik_asuh'];?></td>
            <td><?php echo $row['sekolah'];?></td>
            <td><?php echo $row['kelas'];?></td>
            <td><?php echo $row['tahun_ajaran']." ".$row['semester'];?></td>
            <td><?php echo $row['keterangan'];?></td>
            <td style="text-align: right">
               <?php 
                  echo ($row['debet']!=0)?rupiah($row['debet']):"-";
               ?>
            </td>
            <td style="text-align: right">
               <?php 
                  echo ($row['kredit']!=0)?rupiah($row['kredit']):"-";
               ?>
            </td>
            <td align="right"><?php echo rupiah($row['saldo']);?></td>
        </tr>
        <?php
          }
        ?>
    </table>
</div>
<?php
  echo "$pagination";
  }
?>
</fieldset>